package com.example.cameldemo.config;

import com.tibco.tibjms.TibjmsConnectionFactory;
import org.apache.camel.component.jms.JmsComponent;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.jms.JMSException;

@Configuration
public class TibcoConfig {

    @Bean(value = "tibco")
    public JmsComponent jmsComponent(){
        JmsComponent jmsComponent = new JmsComponent();
        jmsComponent.setConnectionFactory(tibjmsConnectionFactory());
        return jmsComponent;
    }

    @Bean
    @ConfigurationProperties(prefix = "ems.test")
    public TibjmsConnectionFactory tibjmsConnectionFactory(){
        TibjmsConnectionFactory connectionFactory = new TibjmsConnectionFactory();
//        try {
//            connectionFactory.setServerUrl(url);
//            connectionFactory.setUserName(username);
//            connectionFactory.setUserPassword(password);
//        } catch (JMSException e) {
//            e.printStackTrace();
//        }
        return connectionFactory;
    }
}
